import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

class User{
    public String key;
    public String password;
}
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-05-23
 * Time: 17:46
 */
@WebServlet("/post")
public class PostPasswordServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        ObjectMapper post=new ObjectMapper();
        User user=post.readValue(req.getInputStream(),User.class);
        resp.getWriter().write("key: "+user.key+"\n"+"password: "+user.password);
        String s=post.writeValueAsString(user);
        System.out.println(s);
    }
}
